//
//  RHPolicySocCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/3/14.
//

#import "RHPolicySocCell.h"
#import "RHSocCircleView.h"
@interface RHPolicySocCell()

@property (nonatomic ,strong) RHSocCircleView *socCircleView;


@end
@implementation RHPolicySocCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
    }
    return self;
}


-(void)setPolicyModel:(RHPolicyModeModel *)policyModel
{
    _policyModel = policyModel;
    self.socCircleView.isChg = [policyModel.paraKey isEqualToString:@"Emu_chgEndSOC"];
    self.socCircleView.policyModel = policyModel;
}

-(void)setupUI
{
    self.contentView.backgroundColor = CFTabViewBgColor;
    kWeakSelf;
    
    UIView *bgView = kView;
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 8;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(5, 15, 5, 15));
    }];
    
    QMUILabel *chgTipsLab = [[QMUILabel alloc] init];
    [chgTipsLab setText:@"设置SOC阀值，当电池容量降至设定SOC阀值，系统将不再进行充放电。".rh_localized];
    chgTipsLab.numberOfLines = 0;
    [chgTipsLab setTextAlignment:NSTextAlignmentLeft];
    [chgTipsLab setFont:kSYSTEMFONT(12)];
    [chgTipsLab setTextColor:kCOLOR_HEX_A(@"3F4443", 0.6)];
    [bgView addSubview:chgTipsLab];
    [chgTipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.mas_offset(15);
    }];
    
    
    UIView *circleContentView = [[UIView alloc]init];
    circleContentView.backgroundColor = CFTabViewBgColor;
    circleContentView.layer.cornerRadius = 8;
    [bgView addSubview:circleContentView];
    [circleContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.height.offset(kScaleW(130));
        make.top.equalTo(chgTipsLab.mas_bottom).offset(15);
        make.bottom.mas_offset(-15);
    }];
    
    _socCircleView = [[RHSocCircleView alloc]init];
    _socCircleView.userInteractionEnabled = YES;
    _socCircleView.backgroundColor = CFTabViewBgColor;
    _socCircleView.layer.cornerRadius = 8;
    _socCircleView.layer.maskedCorners = YES;
    [circleContentView addSubview:_socCircleView];
    [_socCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.top.bottom.mas_offset(0);
        make.width.equalTo(weakSelf.socCircleView.mas_height).multipliedBy(1.6);
    }];
}
@end
